package com.xinsoft.controller.device;

import com.xinsoft.common.Response;
import com.xinsoft.entity.dto.CusWarnDataPageParam;
import com.xinsoft.service.CusWarnDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cus/warnData")
public class CusWarnDataController {

    @Autowired
    private CusWarnDataService cusWarnDataService;

    /**
     * 获取详情
     */
    @GetMapping("/detail")
    public Response<?> detail(@RequestParam(value = "id", defaultValue = "", required = true) Integer id) {
        return Response.succeed(cusWarnDataService.getCusWarnData(id));
    }

    /**
     * 标记已读
     */

    @Transactional(rollbackFor = Exception.class)
    @PostMapping("/read")
    public Response<?> read(@RequestBody List<Integer> ids) {
        cusWarnDataService.read(ids);
        return Response.succeed();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    @Transactional(rollbackFor = Exception.class)
    public Response<?> del(@RequestBody List<Integer> ids) {
        cusWarnDataService.del(ids);
        return Response.succeed();
    }

    /**
     * 分页
     */
    @PostMapping("/pageList")
    public Response<?> pageList(@RequestBody CusWarnDataPageParam cusWarnDataPageParam) {
        return Response.succeed(cusWarnDataService.findPageListByParam(cusWarnDataPageParam));
    }

}
